﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CLUBsInterpreter.ObjectTypes
{
	/**
	 * <summary>
	 * Describes a string object in the CLUBs environment.
	 * </summary>
	 **/
	class CLUBsString : CLUBsObject
	{
		/**
		 * <summary>
		 * The actual string value.
		 * </summary>
		 **/
		public string InternalString = "";

		/**
		 * <summary>
		 * Default constructor creates empty string.
		 * </summary>
		 **/
		public CLUBsString()
		{
			// Set the object identifier type
			ObjectIdentifierType = AST.IdentifierType.String;
		}

		/**
		 * <summary>
		 * Constructor taking initial value.
		 * </summary>
		 **/
		public CLUBsString(string str)
			: this()
		{
			// Set the internal string to the specified initial value
			InternalString = str;
		}

		/**
		 * <see cref="CLUBsObject.CopyValueFromObject"/>
		 **/
		public override void CopyValueFromObject(CLUBsObject obj)
		{
            CLUBsString stringObj = (CLUBsString)obj;
            InternalString = stringObj.InternalString;
		}

		public override string ToString()
		{
			return InternalString;
		}

		/**
		 * <summary>
		 * Implicit casting operator for easy casting to native C# strings.
		 * </summary>
		 **/
		public static implicit operator string(CLUBsString cs)
		{
			// Return the internal string
			return cs.InternalString;
		}

		/**
		 * <summary>
		 * Implicit casting operator for easy casting from native C# strings.
		 * </summary>
		 **/
		public static implicit operator CLUBsString(string str)
		{
			// Return new CLUBsString with the specified initial value
			return new CLUBsString(str);
		}
	}
}
